import 'package:flutter/material.dart';

class ProgressDemo extends StatefulWidget {
  @override
  ProgressDemoState createState() => ProgressDemoState();
}

class ProgressDemoState extends State<ProgressDemo>
    with SingleTickerProviderStateMixin {
  /** 动画progress */
   late AnimationController _animationController;

  @override
  void initState() {
    _animationController =
        AnimationController(vsync: this, duration: Duration(seconds: 3));
    _animationController.forward();
   _animationController.addListener(() => setState(() => {}));
    // _animationController.addListener(() {
    //   //super.initState();
    // });
        super.initState();

  }
  @override
  void dispose() {
    // TODO: implement dispose
    _animationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
        appBar: AppBar(
          title: Text('progress'),
        ),
        body: Column(
          children: [
            Text('progressDemo'),
            LinearProgressIndicator(
              backgroundColor: Colors.grey[200],
              valueColor: AlwaysStoppedAnimation(Colors.blue),
              value: .5,
            ),
            LinearProgressIndicator(
              backgroundColor: Colors.red,
              valueColor: AlwaysStoppedAnimation(Colors.blue),
            ),
            CircularProgressIndicator(
              backgroundColor: Colors.red,
              valueColor: AlwaysStoppedAnimation(Colors.blue),
            ),
            CircularProgressIndicator(
              backgroundColor: Colors.redAccent,
              valueColor: AlwaysStoppedAnimation(Colors.blue),
              value: 0.5,
            ),
            Text('尺寸改变'),
            SizedBox(
              height: 2,
              child: LinearProgressIndicator(
                backgroundColor: Colors.red,
                valueColor: AlwaysStoppedAnimation(Colors.grey[200]),
                value: .5,
              ),
            ),
            SizedBox(
              height: 100,
              width: 100,
              child: CircularProgressIndicator(
                backgroundColor: Colors.grey[200],
                valueColor: AlwaysStoppedAnimation(Colors.blue),
                value: .7,
              ),
            ),
            Text('动画progress'),
            Padding(padding: EdgeInsets.all(16),
            child: LinearProgressIndicator(
              backgroundColor: Colors.grey[200],
              valueColor: ColorTween(begin: Colors.grey,end: Colors.blue).animate(_animationController),
              value: _animationController.value,
            ),
            )
          ],
        ));
  }

  noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}

/*
class ProgressDemo extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(title: Text('progress'),),
      body: Column(children: [
        Text('progressDemo'),
        LinearProgressIndicator(backgroundColor: Colors.grey[200],
        valueColor: AlwaysStoppedAnimation(Colors.blue),
        value: .5,
        ),
        LinearProgressIndicator(
          backgroundColor: Colors.red,
          valueColor: AlwaysStoppedAnimation(Colors.blue),
        ),
        CircularProgressIndicator(
          backgroundColor: Colors.red,
          valueColor: AlwaysStoppedAnimation(Colors.blue),
        ),
        CircularProgressIndicator(
          backgroundColor: Colors.redAccent,
          valueColor: AlwaysStoppedAnimation(Colors.blue),
          value: 0.5,
        ),
        Text('尺寸改变'),
        SizedBox(
          height: 2,
          child: LinearProgressIndicator(
            backgroundColor: Colors.red,
            valueColor: AlwaysStoppedAnimation(Colors.grey[200]),
            value: .5,
          ),
        ),
        SizedBox(
          height: 100,
          width: 100,
          child: CircularProgressIndicator(
            backgroundColor: Colors.grey[200],
            valueColor: AlwaysStoppedAnimation(Colors.blue),
            value: .7,
          ),
        )
      
      ],)
    );
  }
}*/